<!doctype html>
<script>
let errorCode = -1;

function sendRequest() {
  let status = document.getElementById('status');

  let xhr = new XMLHttpRequest();
  xhr.open("GET", "hung", false);

  status.textContent = 'Sending a request.';
  try {
    xhr.send(null);
  } catch (e) {
    errorCode = e.code;
  }
  status.textContent = `Request completed. errorCode: ${errorCode}.`
}

function getErrorCode() {
  return errorCode;
}

</script>
<body onload="sendRequest()">
This page sends a synchronous XMLHttpRequest that will get cancelled.<br>
Status: <div id="status">Before sending the request.</div>
</body>
